package com.jingogo.service.impl;

import com.jingogo.common.BusinessException;
import com.jingogo.entity.Bill;
import com.jingogo.mapper.BillMapper;
import com.jingogo.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class BillServiceImpl implements BillService {
    @Autowired
    private BillMapper billMapper;

    @Override
    public void addBill(Bill bill) {
        if (bill.getAmount() == null) throw new BusinessException("金额不能为空");
        billMapper.insert(bill);
    }

    @Override
    public void editBill(Bill bill) {
        if (bill.getId() == null) throw new BusinessException("账单ID不能为空");
        billMapper.update(bill);
    }

    @Override
    public void deleteBill(Long billId) {
        billMapper.deleteById(billId);
    }

    @Override
    public List<Bill> listBill() {
        return billMapper.selectAll();
    }
} 